﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GameEngine.Model.Data;
using GameEngine.Model.Data.implementation;
using MapEngine;
using GameEngine.Clients.Silverlight.View.Components;
using System.Collections.Generic;
using System.Windows.Media.Imaging;

namespace SilverlightResources
{
    public class SpriteMaleAndFemale
    {
        static float size = 0.2f;
        static Point3d malefemalescale = new Point3d(new Point(size, size), size);
        static Point3d malefemalescaleinv = new Point3d(new Point(-size, size), size);
        static float malefemalevelocity = 3;
        static float malefemalePositionX = -35 / 2;
        static float malefemalePositionY = -70;

        public static ShapeVOId maleWalkSouthShapeId = new ShapeVOId("maleWalkSouth");
        public static ShapeVOId maleWalkEastShapeId = new ShapeVOId("maleWalkEast");
        public static ShapeVOId maleWalkNorthShapeId = new ShapeVOId("maleWalkNorth");
        public static ShapeVOId maleWalkWestShapeId = new ShapeVOId("maleWalkWest");

        static Rect ser = new Rect(0, 0, 35, 70);   // 35x70
        static Rect nwr = new Rect(35, 0, 70, 70);
        static String se = ItemUC.createSpriteModifiers("maleandfemale", 4, malefemalevelocity, new List<Rect>(){
            new Rect(70,0,105,70),
            new Rect(105,0, 140,70),
            new Rect(140,0, 175,70),
            new Rect(175,0, 210,70)
        });
        static String nw = ItemUC.createSpriteModifiers("maleandfemale", 4, malefemalevelocity, new List<Rect>(){
            new Rect(0,75, 35,150),
        new Rect(35,75, 70,150),  
        new Rect(70,75, 105,150),  
        new Rect(105,75, 140,150),
        });
        static Rect fser = new Rect(245, 0, 280, 75);   // 35x70
        static Rect fnwr = new Rect(280,0, 315, 75);
        static String fse = ItemUC.createSpriteModifiers("maleandfemale", 4, malefemalevelocity, new List<Rect>(){
            new Rect(315,0,  350,70),   
    new Rect(350,0,  385,70),   
    new Rect(385,0,  420,70),  
    new Rect(420,0,  455,70),
    });
        static String fnw = ItemUC.createSpriteModifiers("maleandfemale", 4, malefemalevelocity, new List<Rect>(){
            new Rect(245,75, 280,145),
        new Rect(280,75, 315,145), 
        new Rect(315,75, 350,145),  
        new Rect(350,75, 385,145)
});
        static ShapeVO maleStandSouth = new ShapeVO(new ShapeVOId("maleStandSouth"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        { // cube.Id
            //TypeModifiers = "maleandfemale, 1,1, 0,5, 35,75",
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { ser }),
            //TypeModifiers = "maleandfemale",
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO maleStandEast = new ShapeVO(new ShapeVOId("maleStandEast"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { ser }),
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        static ShapeVO maleStandNorth = new ShapeVO(new ShapeVOId("maleStandNorth"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { nwr }),
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        static ShapeVO maleStandWest = new ShapeVO(new ShapeVOId("maleStandWest"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { nwr }),
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO maleWalkSouth = new ShapeVO(maleWalkSouthShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = se,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO maleWalkEast = new ShapeVO(maleWalkEastShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = se,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };
        
        static ShapeVO maleWalkWest = new ShapeVO(maleWalkWestShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = nw,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO maleWalkNorth = new ShapeVO(maleWalkNorthShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = nw,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        static ShapeVO femaleStandSouth = new ShapeVO(new ShapeVOId("maleStandSouth"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        { // cube.Id
            //TypeModifiers = "maleandfemale, 1,1, 0,5, 35,75",
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { fser }),
            //TypeModifiers = "maleandfemale",
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO femaleStandEast = new ShapeVO(new ShapeVOId("maleStandEast"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { fser }),
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        static ShapeVO femaleStandNorth = new ShapeVO(new ShapeVOId("maleStandNorth"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { fnwr }),
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        static ShapeVO femaleStandWest = new ShapeVO(new ShapeVOId("maleStandWest"), new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = ItemUC.createSpriteModifiers("maleandfemale", 1, 1, new List<Rect>() { fnwr }),
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO femaleWalkSouth = new ShapeVO(maleWalkSouthShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = fse,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO femaleWalkEast = new ShapeVO(maleWalkEastShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = fse,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        static ShapeVO femaleWalkWest = new ShapeVO(maleWalkWestShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = fnw,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescale
        };

        static ShapeVO femaleWalkNorth = new ShapeVO(maleWalkNorthShapeId, new ShapeTypeVOId(ItemUC.ShapeTypeSprite))
        {
            TypeModifiers = fnw,
            Position = new Point3d(new Point(malefemalePositionX, malefemalePositionY), 0),
            Scale = malefemalescaleinv
        };

        //public static ViewStateId deadState = new ViewStateId("dead");
        public static ViewStateVO sitSouthState = new ViewStateVO("sitSouth");
        public static ViewStateVO sitNorthState = new ViewStateVO("sitNorth");
        public static ViewStateVO sitEastState = new ViewStateVO("sitEast");
        public static ViewStateVO sitWestState = new ViewStateVO("sitWest");
        public static ViewStateVO throwSouthState = new ViewStateVO("throwSouth");
        public static ViewStateVO throwNorthState = new ViewStateVO("throwNorth");
        public static ViewStateVO throwEastState = new ViewStateVO("throwEast");
        public static ViewStateVO throwWestState = new ViewStateVO("throwWest");
        public static ViewStateVO punchSouthState = new ViewStateVO("punchSouth");
        public static ViewStateVO punchNorthState = new ViewStateVO("punchNorth");
        public static ViewStateVO punchEastState = new ViewStateVO("punchEast");
        public static ViewStateVO punchWestState = new ViewStateVO("punchWest");
        public static ViewStateVO standSouthState = new ViewStateVO("standSouth");
        public static ViewStateVO standNorthState = new ViewStateVO("standNorth");
        public static ViewStateVO standEastState = new ViewStateVO("standEast");
        public static ViewStateVO standWestState = new ViewStateVO("standWest");
        public static ViewStateVO walkSouthState = new ViewStateVO("walkSouth");
        public static ViewStateVO walkNorthState = new ViewStateVO("walkNorth");
        public static ViewStateVO walkEastState = new ViewStateVO("walkEast");
        public static ViewStateVO walkWestState = new ViewStateVO("walkWest");
        public static ViewStateVO workSouthState = new ViewStateVO("workSouth");
        public static ViewStateVO workNorthState = new ViewStateVO("workNorth");
        public static ViewStateVO workEastState = new ViewStateVO("workEast");
        public static ViewStateVO workWestState = new ViewStateVO("workWest");

        public static IViewVO<int> createMaleView(int id, String name) {

            ViewVO<int> malePeasantView = new ViewVO<int>(new ViewVOId<int>(id) { Name = name });
            malePeasantView.AddShape(maleStandSouth);
            malePeasantView.AddShape(maleStandSouth,standSouthState);
            malePeasantView.AddShape(maleStandNorth,standNorthState);
            malePeasantView.AddShape(maleStandEast,standEastState);
            malePeasantView.AddShape(maleStandWest,standWestState);

            //malePeasantView.AddShapeToState(MyFacade.Instance.punchSouthState, malePunchSouth);

            //malePeasantView.AddShapeToState(MyFacade.Instance.throwSouthState, maleThrowSouth);

            malePeasantView.AddShape(maleWalkSouth,walkSouthState);
            malePeasantView.AddShape(maleWalkEast,walkEastState);
            malePeasantView.AddShape(maleWalkWest,walkWestState);
            malePeasantView.AddShape(maleWalkNorth,walkNorthState);
            return malePeasantView;
        }

        public static IViewVO<int> createFemaleView(int id, String name)
        {
            ViewVO<int> malePeasantView = new ViewVO<int>(new ViewVOId<int>(id) { Name = name});
            malePeasantView.AddShape(femaleStandSouth);
            malePeasantView.AddShape(femaleStandSouth, standSouthState);
            malePeasantView.AddShape(femaleStandNorth, standNorthState);
            malePeasantView.AddShape(femaleStandEast, standEastState);
            malePeasantView.AddShape(femaleStandWest, standWestState);

            //malePeasantView.AddShapeToState(MyFacade.Instance.punchSouthState, malePunchSouth);

            //malePeasantView.AddShapeToState(MyFacade.Instance.throwSouthState, maleThrowSouth);

            malePeasantView.AddShape(femaleWalkSouth, walkSouthState);
            malePeasantView.AddShape(femaleWalkEast, walkEastState);
            malePeasantView.AddShape(femaleWalkWest, walkWestState);
            malePeasantView.AddShape(femaleWalkNorth, walkNorthState);
            return malePeasantView;
        }
    }
}
